# !usr/bin/env python
# -*- coding:utf-8 _*-
"""
@Author:张广勤
@Web site: https://www.tunan.wang
@Github:www.github.com
 
@File:yi_search1_0.py
@Time:2024/8/21 15:02

@Motto:不积跬步无以至千里，不积小流无以成江海！
"""

from yi.yi_class1_0 import yi_dict
import streamlit as st

data = yi_dict

def search_keyword(keyword):
    results = []
    for gua, lines in data.items():
        for line in lines:
            if keyword in line:
                results.append((gua, line))
    return results

st.title('易经关键词查找')

keyword = st.text_input('请输入关键词：')

if keyword:
    results = search_keyword(keyword)
    if results:
        # print(results)
        results_len=len(results)
        st.write(f'找到{results_len}条匹配结果：')
        for gua, line_content in results:
            st.write(f'卦：{gua}')
            st.write(f'行内容：{line_content}')
    else:
        st.write('未找到匹配结果。')